const request = (options) => {
  console.log('Mock API Request:', options);
  return new Promise((resolve, reject) => {
    setTimeout(() => {
      if (options.url.includes('/api/rental')) {
        // Simulate rental API responses
        if (options.url.includes('/api/rental/list')) {
          resolve({
            code: 200,
            data: {
              items: [
                { id: 'R001', name: '豪华公寓', location: '西湖区', price: 5000, deposit_free: true, image: 'https://via.placeholder.com/300x200?text=Apartment1' },
                { id: 'R002', name: '市中心写字楼', location: '上城区', price: 8000, deposit_free: false, image: 'https://via.placeholder.com/300x200?text=Office1' }
              ],
              total: 2
            }
          });
        } else if (options.url.includes('/api/rental/detail')) {
          // Simulate detail response based on ID
          const id = options.url.split('/').pop();
          const item = options.data.items.find(i => i.id === id) || { id: id, name: '未知租赁项', location: '某地', price: 0, deposit_free: false, image: 'https://via.placeholder.com/300x200' };
          resolve({
            code: 200,
            data: item
          });
        } else {
          resolve({ code: 200, message: 'Rental API mock success' });
        }
      } else if (options.url.includes('/api/user')) {
        // Simulate user API responses
        if (options.url.includes('/api/user/info')) {
          resolve({
            code: 200,
            data: {
              id: 'user123',
              username: '西湖分用户',
              creditScore: 655,
              phone: '13800138000'
            }
          });
        } else {
          resolve({ code: 200, message: 'User API mock success' });
        }
      } else if (options.url.includes('/api/social')) {
         resolve({
            code: 200,
            data: {
              items: [
                { id: 'A001', title: '西湖水质监测', type: '护水行动', status: '进行中', time: '2024-06-20 09:00-11:00', location: '西湖边', description: '参与水质监测，保护西湖环境。' },
                { id: 'A002', title: '旧物回收公益', type: '环保行动', status: '已报名', time: '2024-06-15 14:00-16:00', location: '社区回收点', description: '回收旧物，助力环保公益。' }
              ],
              total: 2
            }
          });
      } else if (options.url.includes('/api/transit')) {
           resolve({
            code: 200,
            data: [
              { id: '1', name: '1路', type: 'bus', start_station: '西湖文化广场', end_station: '灵隐寺', first_time: '06:00', last_time: '22:00', interval: '10分钟', price: 2 },
              { id: '2', name: '地铁1号线', type: 'subway', start_station: '湘湖', end_station: '萧山国际机场', first_time: '06:30', last_time: '23:00', interval: '5分钟', price: 4 }
            ]
          });
      } else {
        resolve({ code: 200, message: 'Mock request success' });
      }
    }, 500); // Simulate network delay
  });
};

export default request; 